package shujvjiegou.week8;

import java.util.*;


/**
 * @Author JetZhang
 * @Date 2021/10/30
 */
public class T1 {

    private static Queue<TreeNode> queue_tree;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] str = scan.nextLine().split(" ");
        TreeNode tree = new TreeNode(str[0]);
        for (int i = 1; i < str.length; i++) {
            new T1().insert(tree, str[i]);
        }
        getDepth(tree, 0);
        System.out.println(MaxCount);
    }

    //用队列进行输入操作
    void insert(TreeNode tree, String str) {
        queue_tree = new LinkedList<>();
        queue_tree.add(tree);
        while (!queue_tree.isEmpty()) {
            tree = queue_tree.poll();
            if (!tree.data.equals("None")) {
                if (tree.lChild == null) {
                    tree.lChild = new TreeNode(str);
                    break;
                } else
                    queue_tree.add(tree.lChild);

                if (tree.rChild == null) {
                    tree.rChild = new TreeNode(str);
                    break;
                } else
                    queue_tree.add(tree.rChild);
            }
        }
    }

    static int MaxCount = 0;

    public static void getDepth(TreeNode tree, int position) {
        if (tree != null) {
            if (!tree.data.equals("None")) {
                position++;
                if (position > MaxCount) {
                    MaxCount = position;
                }
                getDepth(tree.lChild, position);
                getDepth(tree.rChild, position);
            }
        }
    }
}

class TreeNode {
    TreeNode lChild;
    TreeNode rChild;
    String data;

    public TreeNode(String data) {
        lChild = null;
        rChild = null;
        this.data = data;
    }
}


//    public static int index = 0;
//    public static BitTreeNode data_root = new BitTreeNode();
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        String str = scanner.nextLine();
//        String[] arr = str.split(" ");
////        BiTree biTree = new BiTree(arr);
////        System.out.println(data_root);
////        System.out.println(biTree.getDepthi1(data_root));
//        System.out.println((int) (Math.log(arr.length) / Math.log(2)) + 1);
//        System.out.println(str);
//    }

